import Vue from 'vue'
import App from './App.vue'
// 导入amfe-flexible插件
import "amfe-flexible"
// 导入重置样式表，去掉标签的默认样式
import "./assets/css/reset.css"
// 导入less,并使用
import less from "less"
Vue.use(less)
// 导入vant-ui 所有组件,并使用
import Vant from "vant"
import "vant/lib/index.css"
import { Lazyload } from "vant"
Vue.use(Vant)
Vue.use(Lazyload)
// 导入路由配置，并挂载vue实例
import router from "./router/index"
// 全局过滤器RMB
Vue.filter("RMBformat", (val) => {
  // console.log(val);
  return "￥" + val + "元"
  // if(val){
  //   return "￥"+val.toFiexed(2)+"元"
  // }
})
Vue.config.productionTip = false
// 全局引入弹出框
import { Dialog } from 'vant';
Vue.use(Dialog);
// 导入vuex 与持久化插件
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    falge: true,
    show: false,
    title: "点击登录",
    back: ">",
    UserFalge: true,
  },
  mutations: {
    chanGe(state) {
      state.falge = !state.falge
    },
    chanGe2(state) {
      state.show = !state.show
    },
    username(state) {
      state.title = localStorage.getItem("token")
        ? localStorage.getItem("username")
        : "点击登录";
    },
    Cback(state) {
      if (state.back === "x") {
        state.back = ">"
      } else {
        state.back = "x"
      }
    },
    Uchange(state) {
      state.UserFalge = !state.UserFalge
    }
  },
  plugins: [createPersistedState({
    storage: window.sessionStorage,
    // 只保留某个存储 数据
    // reducer(val) {
    //   return {
    //     assessmentData: val.falge
    //   }
    // }
  })]
})
// 懒加载
Vue.use(Lazyload, {
  lazyComponent: true,
});

new Vue({
  store,
  router,
  render: h => h(App),

}).$mount('#app')
